package com.jn.erp.web.api.interaction.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jn.erp.common.core.result.AjaxResult;
import com.jn.erp.security.controller.BaseWebAuthController;
import com.jn.erp.web.api.common.entity.TLabel;
import com.jn.erp.web.api.common.service.TLabelService;
import com.jn.erp.web.api.course.entity.TCourseOrderConfig;
import com.jn.erp.web.api.course.service.TCourseOrderConfigService;
import com.jn.erp.web.api.interaction.entity.TEvaluateTemplate;
import com.jn.erp.web.api.interaction.service.TEvaluateTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wyp
 * @since 2024-09-20
 */
@RestController
@RequestMapping("/tEvaluateTemplate")
public class TEvaluateTemplateController extends BaseWebAuthController {
    @Autowired
    private TLabelService tLabelService;

    @Autowired
    private TEvaluateTemplateService tEvaluateTemplateService;

    /**
     评价模版新增新建
     */
    @PostMapping("save")
    public AjaxResult save(@RequestBody  TEvaluateTemplate tEvaluateTemplate){
        //机构id
        tEvaluateTemplate.setOrgId(Long.parseLong(loginDeptAuth()) );
        //当前登录人id
        tEvaluateTemplate.setCreateUser(String.valueOf(getUserId()) );
        tEvaluateTemplate.setIsDelete("0");
        Boolean boo = tEvaluateTemplateService.save(tEvaluateTemplate);
        return AjaxResult.success(boo);
    }



    /**
     评价模版修改
     */
    @PostMapping("update")
    public AjaxResult update(@RequestBody TEvaluateTemplate tEvaluateTemplate){
        //机构id
        tEvaluateTemplate.setUpdateDate(LocalDateTime.now() );
        //当前登录人id
        tEvaluateTemplate.setUpdateUser(String.valueOf(getUserId()) );
        Boolean boo = tEvaluateTemplateService.updateById(tEvaluateTemplate);
        return AjaxResult.success(boo);
    }

    /**
     列表
     */
    @PostMapping("list")
    public AjaxResult templateList(@RequestBody  TEvaluateTemplate tEvaluateTemplate){

        List<TEvaluateTemplate> list = tEvaluateTemplateService.templateList(tEvaluateTemplate);
        return AjaxResult.success(list);
    }



    /**
     评价模版删除
     */
    @PostMapping("delete")
    public AjaxResult delete(@RequestBody TEvaluateTemplate tEvaluateTemplate){
        //机构id
        tEvaluateTemplate.setUpdateDate(LocalDateTime.now() );
        //当前登录人id
        tEvaluateTemplate.setUpdateUser(String.valueOf(getUserId()) );
        tEvaluateTemplate.setIsDelete("1");
        Boolean boo = tEvaluateTemplateService.updateById(tEvaluateTemplate);
        return AjaxResult.success(boo);
    }
}

